package com.shishuo.cms.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.shishuo.cms.constant.UserConstant;
import com.shishuo.cms.entity.UserEntity;

@Controller
public class ClassesIndexAction extends IndexBaseAction{

	@RequestMapping(value = "/article/{aliasName}/{p}", method = RequestMethod.GET)
	public String articleList(@PathVariable String aliasName,
			@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("aliasName", aliasName);
		modelMap.put("p", p);
		return this.getTemplatePath()+"articleList";
	}
	
	@RequestMapping(value = "/article/{aliasName}", method = RequestMethod.GET)
	public String articleListDefault(@PathVariable String aliasName,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return articleList(aliasName,0,request,modelMap);
	}
	
	@RequestMapping(value = "/article_item/{articleId}", method = RequestMethod.GET)
	public String articleItemDefault(@PathVariable long articleId,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("articleId", articleId);
		modelMap.put("p", 0);
		return this.getTemplatePath()+"articleItem";
	}
	@RequestMapping(value = "/video/{aliasName}/{p}", method = RequestMethod.GET)
	public String videoList(@PathVariable String aliasName,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("aliasName", aliasName);
		modelMap.put("p", p);
		return this.getTemplatePath()+"videoList";
	}
	@RequestMapping(value = "/video/{aliasName}", method = RequestMethod.GET)
	public String videoListDefault(@PathVariable String aliasName,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return videoList(aliasName, 0, request, modelMap);
	}
	
	@RequestMapping(value = "/video_item/{videoId}", method = RequestMethod.GET)
	public String videoItemDefault(@PathVariable long videoId,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return videoItem(videoId, 0, request, modelMap);
	}
	@RequestMapping(value = "/video_item/{videoId}/{p}", method = RequestMethod.GET)
	public String videoItem(@PathVariable long videoId,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("videoId", videoId);
		modelMap.put("p", p);
		return this.getTemplatePath()+"videoItem";
	}
	@RequestMapping(value = "/picture/{aliasName}/{p}", method = RequestMethod.GET)
	public String pictureList(@PathVariable String aliasName,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("aliasName", aliasName);
		modelMap.put("p", p);
		return this.getTemplatePath()+"pictureList";
	}
	@RequestMapping(value = "/picture/{aliasName}", method = RequestMethod.GET)
	public String pictureListDefault(@PathVariable String aliasName,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return pictureList(aliasName,0,request,modelMap);
	}
	@RequestMapping(value = "/picture_item/{pictureId}/{p}", method = RequestMethod.GET)
	public String pictureItem(@PathVariable long pictureId,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("pictureId", pictureId);
		modelMap.put("p", p);
		return this.getTemplatePath()+"pictureItem";
	}
	@RequestMapping(value = "/picture_item/{pictureId}", method = RequestMethod.GET)
	public String pictureItemDefault(@PathVariable long pictureId,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return pictureItem(pictureId, 0, request, modelMap);
	}
	@RequestMapping(value = "/single/{aliasName}/{p}", method = RequestMethod.GET)
	public String singleList(@PathVariable String aliasName,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("aliasName", aliasName);
		modelMap.put("p", p);
		return this.getTemplatePath()+"singlePageList";
	}
	@RequestMapping(value = "/single/{aliasName}", method = RequestMethod.GET)
	public String singleListDefault(@PathVariable String aliasName,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return singleList(aliasName,0,request,modelMap);
	}
	
	@RequestMapping(value = "/down/{aliasName}/{p}", method = RequestMethod.GET)
	public String downList(@PathVariable String aliasName,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("aliasName", aliasName);
		modelMap.put("p", p);
		return this.getTemplatePath()+"downPageList";
	}
	@RequestMapping(value = "/down/{aliasName}", method = RequestMethod.GET)
	public String downListDefault(@PathVariable String aliasName,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return downList(aliasName,0,request,modelMap);
	}
	@RequestMapping(value = "/down_item/{id}/{p}", method = RequestMethod.GET)
	public String downItem(@PathVariable long id,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("id", id);
		modelMap.put("p", p);
		return this.getTemplatePath()+"downPageItem";
	}
	@RequestMapping(value = "/down_item/{id}", method = RequestMethod.GET)
	public String downItemDefault(@PathVariable long id,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return downItem(id, 0, request, modelMap);
	}
	@RequestMapping(value = "/goods/{aliasName}/{p}", method = RequestMethod.GET)
	public String goodsList(@PathVariable String aliasName,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap,
			@RequestParam(value = "orderNum",defaultValue="0") int orderNum) throws Exception
	{
		modelMap.put("aliasName", aliasName);
		modelMap.put("p", p);
		modelMap.put("orderNum", orderNum);
		return this.getTemplatePath()+"goodsItemList";
	}
	@RequestMapping(value = "/goods/{aliasName}", method = RequestMethod.GET)
	public String goodsListDefault(@PathVariable String aliasName,
			HttpServletRequest request,ModelMap modelMap,
			@RequestParam(value = "orderNum",defaultValue="0") int orderNum) throws Exception
	{
		return goodsList(aliasName,0,request,modelMap,orderNum);
	}
	@RequestMapping(value = "/goods_item/{id}/{p}", method = RequestMethod.GET)
	public String goodsItem(@PathVariable long id,@PathVariable(value = "p") int p,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("id", id);
		modelMap.put("p", p);
		return this.getTemplatePath()+"goodsItem";
	}
	@RequestMapping(value = "/goods_item/{id}", method = RequestMethod.GET)
	public String goodsItemDefault(@PathVariable long id,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		return goodsItem(id, 0, request, modelMap);
	}
	@RequestMapping(value = "/goods_redirect/{id}", method = RequestMethod.GET)
	public String goodsItemRedirect(@PathVariable long id,
			HttpServletRequest request,ModelMap modelMap) throws Exception
	{
		modelMap.put("id", id);
		modelMap.put("p", 0);
		return this.getTemplatePath()+"goodsRedirect";
	}
	@RequestMapping(value = { "/goods/search/{searchKey}/" , "/goods/search/{searchKey}/index.htm" }, method = RequestMethod.GET)
	public String defaultGoodsItemSearch(ModelMap modelMap,@PathVariable String searchKey,
			@RequestParam(value = "orderNum",defaultValue="0") int orderNum) throws Exception {
		return goodsItemSearch(modelMap,searchKey,0,orderNum);
	}
	@RequestMapping(value = { "/goods/search/{searchKey}/{p}" }, method = RequestMethod.GET)
	public String goodsItemSearch(ModelMap modelMap,@PathVariable String searchKey,@PathVariable(value = "p") int p,
			@RequestParam(value = "orderNum",defaultValue="0") int orderNum) throws Exception {
		modelMap.put("keyWords", searchKey);
		modelMap.put("p", p);
		modelMap.put("orderNum", orderNum);
		return this.getTemplatePath()+"goodsSearch";
	}
	@RequestMapping(value = { "/goods/hotKeywords/{p}"}, method = RequestMethod.GET)
	public String hotKeywords(ModelMap modelMap,@PathVariable(value = "p") int p) throws Exception {
		modelMap.put("p", p);
		return this.getTemplatePath()+"hotKeywords";
	}
	@RequestMapping(value = { "/goods/hotKeywords/" , "/goods/hotKeywords/index.htm" }, method = RequestMethod.GET)
	public String defaultHotKeywords(ModelMap modelMap) throws Exception {
		return hotKeywords(modelMap,1);
	}
}
